<template>
	<view>
		<bg-video></bg-video>
		<cu-custom bgColor="bg-yellow" :isBack="true">
			<block class="text-white" slot="content">申请列表</block>
		</cu-custom>

		<view>
			<view>
				<view class="padding-xs" v-for="(item, index) in zjsqitems" :key="index">
					<view class="margin-sm shadow bg-white padding-xs relative">
						<view class="flex">
							<view class="w-100">
								<view class="padding-xs flex justify-between align-baseline text-lg">
									<text class="">{{item.zjname}}</text>
								</view>
								<view class="padding-xs flex justify-between align-baseline">
									<text>预约时间: {{item.ct}}</text>
								</view>
								<view class="padding-xs flex justify-between align-baseline">
									<button @tap="submit('agree', item)" class="bg-green" size="mini">同意</button>
									<button @tap="submit('reject', item)" class="bg-red" size="mini">拒绝</button>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

			
			<view v-if="zjsqitems.length == 0" class="padding text-center">
				<text>暂无记录</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data: function() {
			return {
				zjgsid: "",
				zjsqitems: []
			};
		},
		onLoad: function(option) {
			this.zjgsid = option.zjgsid;
			this.loadSqitems();
		},
		methods: {
			loadSqitems: function() {
				this.api("/zj/zjsq/all/get").send({
					zjgsid: this.zjgsid
				}).then(data => {
					this.zjsqitems = data.zjsqitems;
				});
			},
			submit: function(option, item) {
				this.api("/zj/zjsq/info/delete").send({
					option,
					item,
				}).then(data => {
					if (option != "agree") {
						option = "拒绝";
					} else {
						option = "处理";
					} 
					this.message.info(option+"成功");
					
					if (data.azj) {
						this.store.commit("submitZj", data.azj);
					}
					if (data.azjgs) {
						this.store.commit("submitZjgs", data.azjgs);
					}
					this.loadSqitems();
				});
			}
		}
	};
</script>

<style>
</style>